<!--
 * @Author: xfworld
 * @Date: 2020-06-10 15:26:04
 * @LastEditors: xfworld
 * @LastEditTime: 2020-06-11 17:10:03
 * @Description: 
-->
<template>
  <div class="scanner">
    <div>This is an Test page</div>
    <van-row style="margin-top: 0.5rem;" type="flex" justify="center">
      <van-col span="6"></van-col>
      <van-col span="6"><van-button hairline type="info" @click="clickEvent">默认按钮</van-button></van-col>
      <van-col span="6"></van-col>
    </van-row>
    <van-row type="flex" justify="center">
      <van-col span="24">
        <van-field v-model="message" rows="10" autosize type="textarea" placeholder="请扫描" />
      </van-col>
    </van-row>
  </div>
</template>
<script>
import {mapGetters} from "vuex";

export default {
  name: "test",
  computed: {
    ...mapGetters("scanner", ["pdaScanData"]),
    message: function() {
      return this.scanData.join("\n");
    }
  },
  watch: {
    pdaScanData: {
      handler(data) {
        this.scanEvent(data.data);
      },
      deep: true
    }
  },
  data() {
    return {
      scanData: []
    };
  },
  methods: {
    clickEvent() {
      this.scanData = [];
      this.$toast.success("扫描数据被清理了");
      //this.scanEvent(Math.random());
    },
    scanEvent(data) {
      this.scanData.push(data);
    },
    scanErrorEvent(error) {
      console.error(error);
    },
    cellClickEvent() {
      this.$toast("点击了");
    }
  }
};
</script>

<style lang="less"></style>
